<!DOCTYPE html>
<html lang="en" dir="ltr">

<head>
  <meta charset="utf-8">
  <title>遇见搜索 - 干净、快速、无竞价排名的搜索引擎</title>
  <link rel="icon" href="./img/logo.png">
  <link rel="stylesheet" href="./css/master.css">
  <link rel="stylesheet" href="./css/common.css">
</head>

<body>
  <div class="container">
    <header>
      <hgroup class="header-hgroup">
        遇见搜索，让你体验无竞价排名的搜索引擎！
      </hgroup>
      <hgroup class="header-hgroup">
        <nav class="header-hgrounp-item">
          <a href="sitemap.html" rel="nofollow">
            遇见网络
          </a>
        </nav>
        <nav class="header-hgrounp-item">
          <a href="./page/test.html" rel="nofollow">程序购买</a>
        </nav>
      </hgroup>
    </header>
    <main class="content">
      <section class="content-item content-log">
        <ul class="content-logo">
          <li class="content-logo-img">
            <img src="./img/logo.png" alt="幽灵">
          </li>
          <li>
            幽灵搜索
          </li>
        </ul>
      </section>
      <!-- 搜索框 -->
      <section class="content-item content-seachinp">
        <div class="searchinp-box">
          <input id="inp" type="text" name="" placeholder="pleace input keyword!">
        </div>
        <div class="searchinp-btn">
          <input type="button" name="" value="搜索一下" id="searchResult">
        </div>
      </section>
      <!-- 搜索关键字 -->
      <section>
        <div class="searchinp-toad">
          <ul class="searchinp-toad-menu">

          </ul>
        </div>
      </section>
      <section class="content-item content-hotlist">
        <ul id="tab">
          <li class="current">实时热点</li>
          <li>今日关注</li>
          <li>七日关注</li>
          <li>网友在搜</li>
        </ul>
        <div id="content">
          <ul style="display:block;">
            <li>
              <span>1</span>网页特效原理分析</li>
            <li>
              <span>2</span>响应用户操作</li>
            <li>
              <span>3</span>提示框效果</li>
            <li>
              <span>4</span>事件驱动</li>
            <li>
              <span>5</span>元素属性操作</li>
            <li>
              <span>6</span>动手编写第一特效</li>
            <li>
              <span>7</span>引入函数</li>
            <li>
              <span>8</span>网页换肤效果</li>
            <li>
              <span>9</span>展播放表效果</li>
            <li>
              <span>5</span>元素属性操作</li>
            <li>
              <span>6</span>动手编写第一特效</li>
            <li>
              <span>7</span>引入函数</li>
            <li>
              <span>8</span>网页换肤效果</li>
            <li>
              <span>9</span>展播放表效果</li>
            <li>
              <span>5</span>元素属性操作</li>


          </ul>
          <ul>
            <li>
              <span>1</span>改变网页背景颜色</li>
            <li>
              <span>2</span>函数传参</li>
            <li>
              <span>3</span>高重用数的编写</li>
            <li>
              <span>4</span>126邮箱全选效果</li>
            <li>
              <span>5</span>循环及遍历操作</li>
            <li>
              <span>6</span>调试器的简单使用</li>
            <li>
              <span>7</span>典型循环的构成</li>
            <li>
              <span>8</span>for合if判断</li>
            <li>
              <span>9</span>className的使用</li>
            <li>
              <span>10</span>innerHTML的使用</li>
            <li>
              <span>11</span>戛纳印象效果</li>
            <li>
              <span>12</span>数组</li>
            <li>
              <span>13</span>字符串连接</li>
          </ul>
          <ul>
            <li>
              <span>1</span>JavaScript组成</li>
            <li>
              <span>2</span>JavaScript</li>
            <li>
              <span>3</span>变量、类型</li>
            <li>
              <span>4</span>简单应用</li>
            <li>
              <span>5</span>其他运算符</li>
            <li>
              <span>6</span>程序流程控制</li>
            <li>
              <span>7</span>命名规范</li>
            <li>
              <span>8</span>函数详解</li>
            <li>
              <span>9</span>定时器的使用</li>
            <li>
              <span>10</span>定时器应用</li>
            <li>
              <span>11</span>定时器应用</li>
            <li>
              <span>12</span>定时器应用</li>
            <li>
              <span>13</span>程序调试法</li>
          </ul>
          <ul>
            <li>
              <span>1</span>网页特效原理分析</li>
            <li>
              <span>2</span>响应用户操作</li>
            <li>
              <span>3</span>提示框效果</li>
            <li>
              <span>4</span>事件驱动</li>
            <li>
              <span>5</span>元素属性操作</li>
            <li>
              <span>6</span>动手编写第一特效</li>
            <li>
              <span>7</span>引入函数</li>
            <li>
              <span>8</span>网页换肤效果</li>
            <li>
              <span>9</span>JavaScript组成</li>
            <li>
              <span>10</span>JavaScript</li>
            <li>
              <span>11</span>变量、类型</li>
            <li>
              <span>12</span>简单应用</li>
            <li>
              <span>13</span>其他运算符</li>
            <li>
              <span>14</span>程序流程控制</li>
          </ul>
        </div>
      </section>
    </main>
    <footer>
      <ul class="box">
        <li>Copyright ©</li>
        <li>HuoDuan.com 京ICP备08010314号</li>
      </ul>
    </footer>
  </div>
</body>

</html>
<script>
  window.onload = function () {
    var oLi = document.getElementById("tab").getElementsByTagName("li");
    var oUl = document.getElementById("content").getElementsByTagName("ul");
    // 关键字
    var searchinp = document.getElementsByClassName('searchinp-box')[0];
    var inpsval = document.getElementById("inp");
    var toads = document.getElementsByClassName("searchinp-toad")[0];
    var toadsItem = toads.children;
    var keywords = ["周杰伦", "周杰伦新专辑", "周杰伦等你下课", "陈奕迅", "陈奕迅演唱会", "陈奕迅歌手",
      "陈奕迅王菲", "前端", "前端开发", "前端入门到放弃", "前端要学什么", "周润发", "周润发赌神", "周润发澳门风云", "周末双休是国家规定吗", "super junior",
      "JavaScript", "Java", "super junior成员", "super junior成员强仁", "super junior成员金英云", "A short journey"];
    // 搜索关键字]
    inpsval.onkeyup = function () {
      toads.innerHTML = "";

      if (this.value) {
        for (var i = 0; i < keywords.length; i++) {
          if (keywords[i].indexOf(this.value) != -1) {
            //如果有匹配到一个元素就创建一个li标签
            var li = document.createElement("li");
            li.innerHTML = keywords[i];
            toads.style.display = "block";
            toads.appendChild(li);
            li.style.color = "black";
            li.style.cursor = 'pointer';
            li.style.padding = 2 + 'px';
            li.onmouseover = function () {
              this.defaultColor = this.style.backgroundColor; //定义一个defaultColor属性来存储li标签本来的背景颜色
              this.style.backgroundColor = "#F1F1F1";
            };

            li.onmouseout = function () {
              this.style.backgroundColor = this.defaultColor;
            };
            // 给生成的lI标签一个点击事件
            li.onclick = function () {
              inpsval.value = this.innerHTML;
            }
          }
        }
      }
    }
    // 点击别的地方让这个关键字检索消失
    document.documentElement.onclick = function () {
      toads.innerHTML = "";
      toads.style.display = "none";
    }
    // 焦点在搜索框中的时候有边框颜色的变化
    inpsval.onfocus = function () {
      searchinp.classList.add('current')
    }
    inpsval.onblur = function () {
      searchinp.classList.remove('current')

    }
    // 选项卡
    for (var i = 0; i < oLi.length; i++) {
      oLi[i].index = i;
      oLi[i].onmouseover = function () {
        for (var n = 0; n < oLi.length; n++) oLi[n].className = "";
        this.className = "current";
        for (var n = 0; n < oUl.length; n++) oUl[n].style.display = "none";
        oUl[this.index].style.display = "block"
      }
    }
    // 跳转搜索的结果页面
    var searchResult = document.getElementById("searchResult");
    searchResult.onclick = function () {
      window.location.href = "./page/newlist.html"
    }
  }
</script>
